let ErrorUtils = require('../utils/error/ErrorUtils');
let {Active} = require('../models');

class BookService {
    static async index(content) {
        return content;
    }

    static async getName(data) {
        if (data.name == 'bobo') {
            ErrorUtils.throwApiError(ErrorUtils.UNKNOW_ERROR);
        }
        let result = await Active.create({
            active_name: 'String',
            prize_name: 'String',
        });
        return result;
    }
    static async getBookInfoById(id){
        if(!id){
            ErrorUtils.throwApiError(ErrorUtils.ID_INVALID);
        }
        //let result=await Active.findById(id);
        // let result=await Active.find()
        //     //.select('prize_code is_show')
        //     .where("is_show",0)
        //     .lean()
        //     .exec();
        // let result=await Active.find()
        //     .lean()
        //     .exec();
        //await Active.update({_id:id},{active_name:"bobo"});
        let result=await Active.findById(id);
        //let result=await Active.findByIdAndUpdate(id,{active_name:'sb'});
        result.active_name="mrosf";
        await result.save();
        return result;
    }

}

module.exports = BookService;